<div class="header_menu">
    <div class="container">
        <div class="header-nav clearfix">
            <?php echo $this->partial('site/headermenu'); ?>
        </div>
    </div>
</div>
</div>
<div class="container breadcrumbs">
    <a href="<?php echo $this->url('shopfront/default'); ?>"><?php echo $this->translate('首页'); ?></a>
    <span class="sep">/</span><span><?php echo $this->translate('订单详情'); ?></span>
</div>
<div class="container">
    <div class="uc-full-box">
        <div class="row">
            <div class="span4">
                <?php echo $this->partial('shopfront/home/left_menu.phtml'); ?>
            </div>
            <div class="span16">
                <div class="xm-line-box uc-box uc-order-detail-box">
                    <div class="box-hd">
                        <h3 class="title">
                            <?php echo $this->translate('订单编号'); ?>：<?php echo $this->order_info->order_sn; ?>
                        </h3>
                        <div class="more">
                            <?php echo $this->translate('订单状态'); ?>：<?php echo $this->frontwebsite()->getOneOrderStateInfo($this->order_info->order_state); ?>
                            <?php if ($this->order_info->order_state == 10) { ?>
                                <a href="javascript:;" onclick="order_pay('<?php echo $this->url('frontorder/default/order_id', array('action'=>'orderpay', 'order_id'=>$this->order_info->order_id)); ?>', <?php echo $this->order_info->order_id; ?>);" class="btn btn-primary btn-small"><?php echo $this->translate('立即付款'); ?></a>
                            <?php } ?>
                            <a href="<?php echo $this->url('frontorder/default/order_page', array('action'=>'index', 'page'=>$this->page, 'order_state'=>$this->order_state)); ?>" class="btn btn-primary btn-small"><?php echo $this->translate('返回订单列表'); ?></a>
                        </div>
                    </div>
                    <div class="box-bd">
                        <div class="order-detail-tables">
                            <table class="order-detail-table">
                                <thead>
                                <tr>
                                    <th colspan="5" class="column-info">
                                        <div class="column-content"><?php echo $this->translate('快递单号'); ?>：
                                            <?php if ($this->delivery_address->express_number != '') { ?>
                                                <?php echo $this->delivery_address->express_number; ?>
                                            <?php } else { echo $this->translate('无'); } ?>
                                        </div>
                                    </th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php foreach ($this->order_goods as $goods_value) { ?>
                                <tr>
                                    <td class="column-detail">
                                        <ul class="order-goods-list">
                                            <li class="first">
                                                <a href="<?php echo $this->url('frontgoods/default', array('goods_id'=>$goods_value['goods_id'], 'class_id'=>$goods_value['class_id'])); ?>" target="_blank"><img alt="<?php echo $this->escapeHtml($goods_value['goods_name']); ?>" src="<?php echo $this->basePath($this->frontwebsite()->shopGoodsImage($goods_value['goods_image'])); ?>" class="goods-thumb"></a>
                                                <a class="goods-name" href="<?php echo $this->url('frontgoods/default', array('goods_id'=>$goods_value['goods_id'], 'class_id'=>$goods_value['class_id'])); ?>" target="_blank"><?php echo $this->escapeHtml($goods_value['goods_name']); ?></a>
                                                <span class="goods-price"><?php echo $this->order_info->currency_symbol . $goods_value['goods_shop_price'] . $this->order_info->currency_unit; ?></span>
                                                <span class="goods-amount">x <?php echo $goods_value['buy_num']; ?></span>
                                            </li>
                                        </ul>
                                    </td>
                                    <td class="column-price">
                                        <div class="order-info order-price"><?php echo $this->escapeHtml($goods_value['goods_item']);?></div>
                                    </td>
                                    <td class="column-date">
                                        <?php
                                        if($goods_value['goods_extend_info']) {
                                            echo $goods_value['goods_extend_info'];
                                        } else {
                                            echo $this->translate('无');
                                        }
                                        ?>
                                    </td>
                                    <td class="column-action">
                                        <strong><?php echo $this->order_info->currency_symbol . $goods_value['goods_amount'] . $this->order_info->currency_unit; ?></strong>
                                    </td>
                                    <td class="column-action">
                                        <?php
                                        if($this->refund_order and !empty($this->refund_order->goods_id_str)) {
                                            $goods_id_array = explode(',', $this->refund_order->goods_id_str);
                                            if(in_array($goods_value['order_goods_id'], $goods_id_array)) echo ' <strong style="color: red;">('.$this->translate('该商品已经退货').')</strong>';
                                        }
                                        ?>
                                    </td>
                                </tr>
                                <?php } ?>
                                <tr>
                                    <td colspan="5" class="column-delivery">
                                        <div class="order-delivery-status">
                                            <ol class="order-delivery-steps clearfix">
                                                <li class="step step-first step-now">
                                                    <div class="progress">
                                                        <span class="text"><?php echo $this->translate('下单时间'); ?></span>
                                                    </div>
                                                    <div class="info"><?php echo date("Y".$this->translate('年')."m".$this->translate('月')."d".$this->translate('日')." H".$this->translate('时')."i".$this->translate('分'), $this->order_info->order_time); ?></div>
                                                </li>
                                                <li class="step <?php if($this->order_info->pay_time != '') echo 'step-now'; ?>">
                                                    <div class="progress">
                                                        <span class="text"><?php echo $this->translate('付款时间'); ?></span>
                                                    </div>
                                                    <div class="info">
                                                        <?php if($this->order_info->pay_time != '') echo date("Y".$this->translate('年')."m".$this->translate('月')."d".$this->translate('日')." H".$this->translate('时')."i".$this->translate('分'), $this->order_info->pay_time); ?>
                                                    </div>
                                                </li>
                                                <li class="step <?php if($this->order_info->express_time != '') echo 'step-now'; ?>">
                                                    <div class="progress">
                                                        <span class="text"><?php echo $this->translate('发货时间'); ?></span>
                                                    </div>
                                                    <div class="info">
                                                        <?php if($this->order_info->express_time != '') echo date("Y".$this->translate('年')."m".$this->translate('月')."d".$this->translate('日')." H".$this->translate('时')."i".$this->translate('分'), $this->order_info->express_time); ?>
                                                    </div>
                                                </li>
                                                <li class="step step-last <?php if($this->order_info->finish_time != '') echo 'step-now'; ?>">
                                                    <div class="progress">
                                                        <span class="text"><?php echo $this->translate('完成时间'); ?></span>
                                                    </div>
                                                    <div class="info">
                                                        <?php if($this->order_info->finish_time != '') echo date("Y".$this->translate('年')."m".$this->translate('月')."d".$this->translate('日')." H".$this->translate('时')."i".$this->translate('分'), $this->order_info->finish_time); ?>
                                                    </div>
                                                </li>
                                            </ol>
                                        </div>
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                            <div class="order-detail-total clearfix">
                                <?php if ($this->order_info->integral_num > 0) { ?>
                                    <p style="text-align: right;margin-bottom: 10px;"><?php echo $this->translate('消费积分'); ?>(<?php if ($this->order_info->integral_rule_info != '') {echo $this->order_info->integral_rule_info . ',&nbsp;';} echo $this->translate('交易完成确认收货后才得到积分'); ?>)：<font size="4" color="#ff4a00"><?php echo $this->order_info->integral_num; ?><?php echo $this->translate('积分'); ?></font></p>
                                <?php } ?>
                                <?php if ($this->order_info->integral_type_2_num > 0) { ?>
                                    <p style="text-align: right;margin-bottom: 10px;"><?php echo $this->translate('等级积分'); ?>(<?php if ($this->order_info->integral_type_2_num_rule_info != '') {echo $this->order_info->integral_type_2_num_rule_info . ',&nbsp;';} echo $this->translate('交易完成确认收货后才得到积分'); ?>)：<font size="4" color="#ff4a00"><?php echo $this->order_info->integral_type_2_num; ?><?php echo $this->translate('积分'); ?></font></p>
                                <?php } ?>
                                <dl class="total-list">
                                    <?php if($this->order_info->goods_weight_amount > 0) { ?>
                                    <dt><?php echo $this->translate('商品总重量'); ?>：</dt>
                                    <dd><?php echo $this->order_info->goods_weight_amount.'</font>'.$this->translate('千克'); ?></dd>
                                    <?php } ?>
                                    <dt><?php echo $this->translate('商品总计'); ?>：</dt>
                                    <dd><?php echo $this->order_info->currency_symbol . $this->order_info->goods_amount; ?></dd>
                                    <dt><?php echo $this->translate('购买优惠'); ?>：</dt>
                                    <dd><?php echo '-'.$this->order_info->currency_symbol . $this->order_info->buy_pre_fee; ?></dd>
                                    <dt><?php echo $this->translate('会员优惠'); ?>：</dt>
                                    <dd><?php echo '-'.$this->order_info->currency_symbol . $this->order_info->user_pre_fee; ?></dd>
                                    <?php if($this->order_info->coupon_pre_fee > 0) { ?>
                                        <dt><?php echo $this->translate('优惠券优惠'); ?>：</dt>
                                        <dd><?php echo '-'.$this->order_info->currency_symbol . $this->order_info->coupon_pre_fee; ?></dd>
                                    <?php } ?>
                                    <?php if(isset($this->order_info->integral_buy_price) and $this->order_info->integral_buy_price > 0) { ?>
                                        <dt><?php echo $this->translate('积分购买'); ?>：</dt>
                                        <dd><?php echo '-'.$this->order_info->currency_symbol . $this->order_info->integral_buy_price; ?></dd>
                                    <?php } ?>
                                    <?php
                                    if(isset($this->order_amount_log) and !empty($this->order_amount_log)) {
                                        foreach($this->order_amount_log as $amount_log) {
                                            ?>
                                            <dt><?php echo $amount_log['order_edit_amount_info']; ?>：</dt>
                                            <dd><?php echo $amount_log['order_edit_amount_type']; ?><?php echo $this->order_info->currency_symbol.ltrim($amount_log['order_edit_number'], '-'); ?></dd>
                                        <?php } } ?>
                                    <dt><?php echo $this->translate('商品运费'); ?>：</dt>
                                    <dd><?php echo $this->order_info->currency_symbol . $this->order_info->express_fee; ?></dd>
                                    <dt><?php echo $this->translate('支付手续'); ?>：</dt>
                                    <dd><?php echo $this->order_info->currency_symbol . $this->order_info->pay_fee; ?></dd>
                                    <dt><?php echo $this->translate('订单总额'); ?>：</dt>
                                    <dd><b><?php echo $this->order_info->currency_symbol . $this->order_info->order_amount ?></b><?php echo $this->order_info->currency_unit; ?></dd>
                                </dl>
                            </div>
                        </div>
                    </div>
                    <div class="order-delivery-address">
                        <?php if (isset($this->order_info->invoice_content) and !empty($this->order_info->invoice_content)) { ?>
                        <div class="order-text-section">
                            <h4><?php echo $this->translate('购物发票'); ?> </h4>
                            <table class="order-text-table">
                                <tbody>
                                    <tr>
                                        <td><?php echo $this->escapeHtml($this->order_info->invoice_content); ?></td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                        <?php } ?>

                        <div class="order-text-section">
                            <h4><?php echo $this->translate('支付信息'); ?></h4>
                            <table class="order-text-table">
                                <tbody>
                                <tr>
                                    <th><?php echo $this->translate('支付方式'); ?>：</th>
                                    <td><?php echo $this->order_info->pay_name; ?></td>
                                </tr>
                                <?php if ($this->order_info->pay_code == 'xxzf' and $this->order_info->pay_certification != '') { ?>
                                    <tr>
                                        <th><?php echo $this->translate('支付证明'); ?>：</th>
                                        <td><?php echo $this->escapeHtml($this->order_info->pay_certification); ?></td>
                                    </tr>
                                <?php } ?>
                                </tbody>
                            </table>
                        </div>
                        <?php if($this->order_log) { ?>
                        <div class="order-text-section">
                            <h4 style="color: red;"><?php echo $this->translate('取消说明'); ?></h4>
                            <table class="order-text-table">
                                <tbody>
                                <?php foreach($this->order_log as $log_value) { ?>
                                <tr style="color: red;">
                                    <th><?php echo $log_value['log_user']; ?>：</th>
                                    <td><?php echo $this->escapeHtml($log_value['state_info']); ?></td>
                                </tr>
                                <?php } ?>
                                </tbody>
                            </table>
                        </div>
                        <?php } ?>
                        <?php if ($this->delivery_address) { ?>
                        <div class="order-text-section">
                            <h4><?php echo $this->translate('配送信息'); ?> </h4>
                            <table class="order-text-table">
                                <tbody>
                                <tr>
                                    <th><?php echo $this->translate('收货人员'); ?>：</th>
                                    <td><?php echo $this->escapeHtml($this->delivery_address->delivery_name); ?></td>
                                </tr>
                                <tr>
                                    <th><?php echo $this->translate('快递信息'); ?>：</th>
                                    <td><?php echo $this->escapeHtml($this->delivery_address->express_name); ?></td>
                                </tr>
                                <?php if ($this->delivery_address->express_number != '') { ?>
                                <tr>
                                    <th><?php echo $this->translate('快递单号'); ?>：</th>
                                    <td><?php echo $this->delivery_address->express_number; ?></td>
                                </tr>
                                <?php } ?>
                                <tr>
                                    <th><?php echo $this->translate('收货地址'); ?>：</th>
                                    <td>
                                        <?php
                                        echo $this->escapeHtml($this->delivery_address->region_address).'<br>';
                                        $region_array = @explode(' ', $this->delivery_address->region_info);
                                        $region_array = array_reverse($region_array);
                                        echo $this->escapeHtml(implode(', ', $region_array));
                                        ?>
                                    </td>
                                </tr>
                                <?php if($this->delivery_address->zip_code) { ?>
                                <tr>
                                    <th><?php echo $this->translate('邮政编码'); ?>：</th>
                                    <td><?php echo $this->escapeHtml($this->delivery_address->zip_code); ?></td>
                                </tr>
                                <?php } ?>
                                <?php if($this->delivery_address->mod_phone) { ?>
                                    <tr>
                                        <th><?php echo $this->translate('手机号码'); ?>：</th>
                                        <td><?php echo $this->escapeHtml($this->delivery_address->mod_phone); ?></td>
                                    </tr>
                                <?php } ?>
                                <?php if($this->delivery_address->tel_phone) { ?>
                                    <tr>
                                        <th><?php echo $this->translate('固定电话'); ?></th>
                                        <td><?php echo $this->escapeHtml($this->delivery_address->tel_phone); ?></td>
                                    </tr>
                                <?php } ?>
                                <?php if (isset($this->order_info->order_message) and !empty($this->order_info->order_message)) { ?>
                                <tr>
                                    <th><?php echo $this->translate('买家留言'); ?>：</th>
                                    <td><?php echo $this->escapeHtml($this->order_info->order_message); ?></td>
                                </tr>
                                <?php } ?>
                                </tbody>
                            </table>
                        </div>

                        <?php if(!empty($this->delivery_address->express_time_info)) { ?>
                        <div class="order-text-section">
                            <h4><?php echo $this->translate('送货时间'); ?> </h4>
                            <div class="order-text-section">
                                <div class="order-delivery-time" id="timeSection"><?php echo $this->escapeHtml($this->delivery_address->express_time_info); ?></div>
                            </div>
                        </div>
                        <?php } } ?>
                        <?php if (isset($this->express_state_array)) { ?>
                        <div class="order-text-section">
                            <h4><?php echo $this->translate('物流信息'); ?> </h4>
                            <div class="order-text-section">
                                <?php if(isset($this->express_state_array['api_type']) and !empty($this->express_state_array['api_type'])) { ?>
                                    <?php echo $this->express_state_array['content']; ?>
                                <?php } ?>
                            </div>
                        </div>
                        <?php } ?>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<form class="form-horizontal" name="pay_form" id="pay_form" action="" method="post">
    <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h3 id="myModalLabel"><?php echo $this->translate('订单付款'); ?>&nbsp;[<?php echo $this->translate('订单号'); ?>：<span id="order-sn"></span>]</h3>
        </div>
        <div class="modal-body" id="pay-list-show">

        </div>
        <div class="modal-footer">
            <input type="hidden" name="payment_pee" id="payment_pee" value="">
            <strong><?php echo $this->translate('订单金额'); ?>：<span id="order-amount"></span></strong>&nbsp;&nbsp;
            <button type="submit" class="btn btn-primary"><?php echo $this->translate('点击支付'); ?></button>
        </div>
    </div>
</form>
<script>
    /**
     * 点击支付的操作
     * @param pay_url
     * @param order_id
     */
    function order_pay(pay_url, order_id) {
        $("#pay_form").attr('action',pay_url);
        $('#pay-list-show').html('');

        $.post('<?php echo $this->url('frontorder/default/order_id', array('action'=>'getOrderPay')); ?>', {'order_id':order_id}, function(data){
                if (data)
                {
                    if(data.state != 'true') {
                        alert(data.message);
                        return;
                    }

                    $('#order-amount').html(data['order']['order_amount']);
                    $('#order-sn').html(data['order']['order_sn']);
                    $('#payment_pee').val(data['order']['pay_fee']);

                    var html = '';
                    for(var i in data['payment']){
                        html += '<div class="control-group">';
                        html += '<label class="control-label" style="width: 80px;">';
                        html += '<input type="radio" name="payment_code" onclick="order_fee(\''+data['payment'][i]['editaction']+'\');" value="'+data['payment'][i]['editaction']+'" '+(data['payment'][i]['editaction']==data['order']['pay_code'] ? "checked" : '')+' >';
                        html += '</label>';
                        html += '<div class="controls" style="margin-left: 90px;">';
                        html += '<img src="<?php echo $this->basePath(); ?>'+data['payment'][i]['payment_logo']['content']+'" style="border:1px solid #D7D7D7; margin-left:8px;">';
                        html += '&nbsp;<input type="hidden" name="payment_price_'+data['payment'][i]['editaction']+'" id="payment_price_'+data['payment'][i]['editaction']+'" value="'+data['payment'][i]['payment_fee']['content']+'">'+data['payment'][i]['payment_name']['content'];
                        if(data['payment'][i]['payment_fee']['content'] > 0) {
                            html += '&nbsp;&nbsp;[<strong><?php echo $this->translate('支付手续费'); ?>：'+data['payment'][i]['payment_fee']['content']+'</strong>]';
                        }
                        html += '</div></div>';
                    }
                    $('#pay-list-show').html(html);
                }
            },
            'json');

        $('#myModal').modal('show');
    }
    function order_fee(payment_code) {
        var order_amount = Subtr(parseFloat($('#order-amount').html()), $('#payment_pee').val());
        order_amount = accAdd(order_amount, $('#payment_price_'+payment_code).val());

        $('#payment_pee').val($('#payment_price_'+payment_code).val());
        $('#order-amount').html(order_amount);
    }
</script>